using System;
using roster.Domain;

namespace roster.UI
{
    public class PlayerController : IPlayerController
    {
        private readonly IPlayerView m_PlayerView;
        public event Action<IPlayer> AddPlayer;

        public PlayerController(IPlayerView playerView)
        {
            m_PlayerView = playerView;
            m_PlayerView.AddPlayer += m_PlayerView_AddPlayer;
        }

        private void m_PlayerView_AddPlayer()
        {
            AddPlayer(new Player(m_PlayerView.PlayerName, m_PlayerView.Class));
        }

        public void GetPlayer()
        {
            m_PlayerView.Display();
        }
    }
}